package com.yykj.user.center.server.repository.patient;

import com.yykj.user.center.server.model.Evaluation;
import com.yykj.user.center.server.model.Patient;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author chenl
 * @version 1.0
 * @date 2021/10/20 22:24
 */
@Repository
public interface EvaluationRepository extends JpaRepository<Evaluation, String>, JpaSpecificationExecutor<Evaluation> {


    List<Evaluation> findByDoctorIdAndStateOrderByAddTimeDesc(String doctorId, Boolean state);

    List<Evaluation> findAllByDoctorId(String doctorId);

    List<Evaluation> findAllByConsultationId(String consultationId);

    @Query("SELECT doctorId,count(*) as count,SUM(score) as total from Evaluation t \n" +
            "where t.doctorId in (?1) \n" +
            "group by t.doctorId")
    List scoreByDoctorIdInGroup(List<String> doctorIds);
}
